package com.yhd.controller;

import com.yhd.entity.dto.CycleImgDto;
import com.yhd.entity.dto.TCorporateDto;
import com.yhd.entity.query.CorporateVO;
import com.yhd.entity.query.CycleImgVO;
import com.yhd.entity.result.ResultVo;
import com.yhd.service.CorporateService;
import com.yhd.service.CycleImgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@Api(value = "企业管理")
@Slf4j
@RequestMapping(value = "/corporate")
@CrossOrigin
public class CorporateController extends WebBaseController {

    @Autowired
    private CorporateService corporateService;


    @ApiOperation(value = "获取企业详情", notes = "获取企业详情")
    @ApiImplicitParams({})
    @GetMapping("/info")
    @ResponseBody
    public ResultVo<TCorporateDto> selectCycleImgInfo(){
        TCorporateDto tCorporateDto = corporateService.ourInfo();
        return ResultVo.success(tCorporateDto);
    }

    @ApiOperation(value = "新增/修改企业", httpMethod = "POST", notes = "{\n" +
            "  \"id\": \"企业id 修改不能为空\",\n" +
            "  \"content\": \"企业信息\",\n" +
            "  \"phone1\": \"400电话\",\n" +
            "  \"wechatId\": \"微信号\"\n" +
            "}")
    @PostMapping("/putCorporate")
    @ResponseBody
    public ResultVo<TCorporateDto> putCorporate(@RequestBody CorporateVO corporateVO) {
        TCorporateDto tCorporateDto = corporateService.putCorporate(corporateVO,getUserInfo(request));
        if (null != tCorporateDto){
            return ResultVo.success(tCorporateDto);
        }
        return ResultVo.failure("10003","操作失败。");
    }

    @ApiOperation(value = "删除企业", httpMethod = "DELETE", notes = "{\n" +
            "  \"id\": \"bannerid\"\n" +
            "}")
    @DeleteMapping("/delete")
    @ResponseBody
    public ResultVo<Boolean> deleteCorporate(@RequestBody CorporateVO corporateVO) {
        boolean deleteCorporate = corporateService.deleteCorporate(corporateVO);
        if (deleteCorporate){
            return ResultVo.success(deleteCorporate);
        }
        return ResultVo.failure("10003","操作失败。");
    }

}
